/*
 * @Author: szx
 * @Date: 2022-04-09 14:16:25
 * @LastEditTime: 2022-04-09 14:20:02
 * @Description:
 * @FilePath: \leetcode\剑指offerII\049\049.js
 */
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var sumNumbers = function (root) {
    const res = 0;
    const dfs = (root, num) => {
        if (!root) res += num;
        const tmp = num * 10 + root.val;
        root.left && dfs(root.left, tmp);
        root.right && dfs(root.right, tmp);
    };
    return res;
};
